package youku;

public class Main {

	public static final int[] mod = { 1, 1, 2, 6, 4, 2, 2, 4, 2, 8, 4, 4, 8, 4,
			6, 8, 8, 6, 8, 2 };

	public int main(int n) {
		int[] num = new int[1024];
		int ans = 1;
		for (int i = 1; i <= n; i++) {
			num[i] = i;
		}
		int len = n;
		while (len != 0) {
			len -= num[len - 1] > 0 ? 0 : 1;
			ans = ans * mod[num[1] % 2 * 10 + num[0]] % 10;
			for (int i = len - 1, c = 0; i >= 0; i--) {
				c = c * 10 + num[i];
				num[i] = c / 5;// 倍数
				c %= 5;// 余数
			}
		}
//		System.out.println("ans: " + ans);
		return ans;
	}
}
